package com.kang.controller;

import com.github.pagehelper.PageInfo;
import com.kang.bean.blog.Article;
import com.kang.commons.Result;
import com.kang.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;


/**
 * @program: service
 * @description:
 * @author: K.faWu
 * @create: 2022-04-20 16:53
 **/
@RestController
@RequestMapping("article")
public class ArticleController {
    @Autowired
    private ArticleService articleService;


    @PostMapping("/save")
    public Result<?> save(@RequestBody Article article, HttpServletRequest request){
        articleService.saveArticle(article, request);
        return Result.success();
    }

    /**
     * 页面展示
     */
    @PostMapping
    public Result<PageInfo<Article>> query(@RequestBody Article article, Pageable page) {
        PageInfo<Article> pageInfo = articleService.queryByPage(article, page);
        return Result.success(pageInfo);
    }

}
